import 'package:flutter/material.dart';
import 'package:srg_flutter_demo/model/post.dart';

class CangcuPage extends StatelessWidget {


  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return  Scaffold(
      
      appBar:   AppBar(title: Text("云宝鲜",style: TextStyle(
        color: Colors.white,

      ),textAlign: TextAlign.center,textDirection: TextDirection.ltr,),
      centerTitle: true,
      iconTheme: IconThemeData(color: Colors.white,opacity:1,size: 24.0),
      actions: <Widget>[
        IconButton(icon: Icon(Icons.add,color: Colors.white), onPressed: ()=>debugPrint("111"),)
      ],
      leading: IconButton(icon: Icon(Icons.notifications,textDirection: TextDirection.ltr,color: Colors.white,), onPressed: ()=>debugPrint("222"),),
      ),
      body: MainListView(),
    );
  }

}


class MainListView extends StatefulWidget{

  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return MainListViewState();
  }
}

class MainListViewState extends State<MainListView> {

  Widget _listItemBuilder(BuildContext context,int  index){
    return  Container(
      color:Colors.white,
      margin: EdgeInsets.all(8.0),
      child: Column(
        children: <Widget>[
          Image.network(posts[index].imageUrl),
          SizedBox(height: 10,),
          Text(posts[index].title,
            style: Theme.of(context).textTheme.title,
          ),
          SizedBox(height: 10,),
          Text(posts[index].author,
            style: Theme.of(context).textTheme.subtitle,
          ),
          SizedBox(height: 16,),

          Text(posts[index].description)
        ],
      ),
    );
  }
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return ListView.builder(itemBuilder: _listItemBuilder,itemCount:posts.length);
  }
}